﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Brjnk.GpxExplorer.Workspace;
using Brjnk.GpxExplorer.Workspace.GCBrowser;

namespace Brjnk.GpxExplorer.UI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class GCBrowserWindow : Window
    {
        private DataModel data;

        public GCBrowserWindow(DataModel data)
        {
            this.data = data;
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = new GcBrowser(data);
        }

        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                var tab = ((BrowserTab)((TextBox)sender).DataContext);
                tab.UpdateLocationCommand.Execute(null);
            }
        }
    }
}